let ajaxCount = 0
export const request = (params) => {
    ajaxCount += 1
    wx.showLoading({
        title: '加载中',
    })
    return new Promise((res, rej) => {
        //http://111.67.198.176:8112
        const baseUrl = 'http://111.67.198.176:8112'
        wx.request({
            ...params,
            url: baseUrl + params.url,
            header: {
                'Authorization': wx.getStorageSync('token')
            },
            //成功
            success: (result) => {
                res(result.data)
            },
            //失败
            fail: (error) => {
                rej(error)
            },
            // 成功或失败都会执行
            complete: () => {
                ajaxCount -= 1
                if (ajaxCount === 0) {
                    wx.hideLoading()
                }
            }
        })
    })
}